package AIRProject.filemanager
{
	import flash.xml.XMLNode;
	public class XmlMaker
	{
		public function XmlMaker()
		{
		}
		
		public static function makeFolder(s:FolderClass):XMLNode
		{
			var node:XMLNode;
			
			
			node = new XMLNode(1,"folder");
			node.attributes.name=s.label;
			if (s.children != null)
			{
				var str:String;
				for (var i:uint=0; i<s.children.length; i++)
				{
					var _file:FolderClass = s.children[i] as FolderClass;
					
					if (_file.isFolder == 0)
					{
						if (_file.children.length > 0)
						{
							node.appendChild(makeFolder(_file));
						}
					}
					else
					{
						node.appendChild(makeFile(_file));
					}
					
				}
			}
			else
			{
				node.appendChild(makeFile(s));
			}
			
			return node;
		}
		
		
		
		
		public static function makeFile(s:FolderClass):XMLNode
		{
			var node_0:XMLNode=new XMLNode(1,"file");
			var node_1:XMLNode=new XMLNode(1,"name");
			var node_2:XMLNode=new XMLNode(3,s.label);
			var node_3:XMLNode=new XMLNode(1,"path");
			var node_4:XMLNode=new XMLNode(3,s.path);
			
			node_0.appendChild(node_1);
			node_1.appendChild(node_2);
			node_0.appendChild(node_3);
			node_3.appendChild(node_4);
			
			
			return node_0;
		}
	}
}